# Please install OpenAI SDK first: `pip3 install openai`
import os
from openai import OpenAI
from dotenv import load_dotenv

load_dotenv()


def call_deepseek_model(prompt):
    client = OpenAI(api_key=os.getenv('DEEPSEEK_KEY'), base_url="https://api.deepseek.com")

    response = client.chat.completions.create(
        model="deepseek-chat",
        messages=[
            {"role": "system", "content": "You are a helpful assistant"},
            {"role": "user", "content": prompt},
        ],
        stream=False
    )

    return response.choices[0].message.content
    # print(response.choices[0].message.content)


if __name__ == '__main__':
    call_deepseek_model(f'''
        你是一个术语提取专家。请从以下中文文本中提取术语，翻译为英文，并给出英文例子。严格按照以下 JSON 格式输出，每个术语独立为一个对象，并按编号排列，编号作为每个术语的 key。只输出 JSON，格式如下：

        {{
            "1": {{"chinese":"术语1","english":"术语1的英文","example":"术语1的英文例句"}},
            "2": {{"chinese":"术语2","english":"术语2的英文","example":"术语2的英文例句"}},
            ...
        }}

        记住：每个术语的输出格式必须是：
        "编号": {{"chinese":"","english":"","example":""}}

        文本内容：刷牙对牙釉质好吗                                                                                                                            
        ''')
